|
|
|
|
|
|
|
Listing 21.16. Coding the CheckUser routine. |
|
|
|
|
|
|
|
|
Private Function CheckUser(strUserID As String, strPassword As String) As
Boolean
'
' check login parms against table
'
Dim strFind As String
'
strFind = "UserID = '" & strUserID & "' AND Password='" & strPassword & "'"
'
If blnUsersLoaded = False Then
LoadUsers
End If
'
rsUsers.FindFirst strFind
If rsUsers.NoMatch = True Then
CheckUser = False
Else
CheckUser = True
End If
'
End Function |
|
|
|
|
|
|
|
|
This routine first checks to see if the dataset containing the users is already loaded. If not, the LoadUsers method is called. Then, the method searches the dataset for the User ID and password in a single record. If all is okay, the routine updates the LastLogIn field of the dataset and exits. If the search comes up empty, the routine reports a value of FALSE upon exit. |
|
|
|
|
|
|
|
|
Now add the Private subroutine LoadUsers from Listing 21.17. |
|
|
|
|
|
|
|
|
Listing 21.17. Coding the LoadUsers method. |
|
|
|
|
|
|
|
|
Private Sub LoadUsers()
'
' load users data set
'
Dim strSQL As String
'
strSQL = "SELECT * FROM secUsers ORDER BY UserID"
'
Set wsUsers = DBEngine.CreateWorkspace("usrLogin", "admin", "")
Set dbUsers = wsUsers.OpenDatabase(strDBName)
Set rsUsers = dbUsers.OpenRecordset(strSQL, dbOpenDynaset)
'
blnUsersLoaded = True
'
End Sub |
|
|
|
|
|